package thread;

public class SleepDemo2 {
    public static void main(String[] args) {
        Thread ly=new Thread("刘阳"){
            public void run(){
                System.out.println(getName()+"正在敲代码");
                try {
                    Thread.sleep(10000);
                } catch (InterruptedException e) {
                    System.out.println("谁呀，干嘛呀");
                }
                System.out.println(getName()+"代码敲完了,说了一句:可以");
            }
        };
        Thread wb=new Thread("王宝强"){
            public void run(){
                System.out.println(getName()+"一起打游戏吗");
                try {
                    Thread.sleep(5000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(getName()+"问一下刘阳吧");
                ly.interrupt();
            }
        };
        ly.start();
        wb.start();
    }
}
